package org.ohos.rajawali3d.slice;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Component;
import ohos.agp.components.Image;
import org.ohos.rajawali3d.ResourceTable;
import org.ohos.rajawali3d.examples.examples.lights.GLESImpl;
import org.rajawali3d.util.RajLog;


public class MainAbilitySliceB extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        RajLog.setDebugEnabled(true);
        findComponentById(ResourceTable.Id_btn_test1).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                //present(new SpotLightFragment(),new Intent());
                // present(new TestFragment2(),new Intent());
                //present(new BasicFragment(),new Intent());
            }
        });

        findComponentById(ResourceTable.Id_btn_test3).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                //present(new SpotLightFragment(),new Intent());
                //present(new TestFragment2(),new Intent());
                //present(new BasicFragment(),new Intent());
            }
        });

        findComponentById(ResourceTable.Id_btn_test2).setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intent = new Intent();
                Operation operation = new Intent.OperationBuilder()
                        .withDeviceId("")
                        .withBundleName("org.ohos.rajawali3d")
                        .withAbilityName("org.ohos.rajawali3d.MainAbility2")
                        .build();
                intent.setOperation(operation);
                startAbility(intent);

            }
        });


        Image image = (Image) findComponentById(ResourceTable.Id_image);
        image.setPixelMap(GLESImpl.getPixelMapFromResource(this, ResourceTable.Media_earthtruecolor_nasa_big));

    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
